/*
 * @Description: 获取文件句柄，也就是文件的操作对象
 * @Author: dh
 * @Date: 2021-09-02 16:51:50
 * @LastEditors: dh
 * @LastEditTime: 2023-10-24 10:41:01
 */

const fs = require('node:fs/promises')

;(async () => {
	let filehandle
	try {
		// 返回该文件的句柄，相当于文件的操作都在句柄上
		filehandle = await fs.open('README.md', 'r')
		filehandle.readFile('utf-8').then(res => {
			console.log(res)
		})
	} finally {
		// 关闭句柄，释放内存
		filehandle?.close()
	}
})()
